package com.liuceng.lib.gdt.utils

import com.liuceng.peatio.utils.AppUtils
import spock.lang.Specification

/**
 * Created by yanwen on 16-5-11.
 */
class AppUtilsSpec extends Specification {
    def "测试 账号流水生成的时间" (){
        given:
        //rptdate
        Date date1=new Date(2016 - 1900, 5 - 1, 11)
        //createdAt
        Date date2=new Date(2016 - 1900, 5 - 1, 11,8,0,0)
        Date date3=new Date(2016 - 1900, 5 - 1, 12,8,0,0)
        Date date4=new Date(2016 - 1900, 5 - 1, 12,9,59,0)
        Date date5=new Date(2016 - 1900, 5 - 1, 11)
        Date date6=new Date(2016 - 1900, 5 - 1, 11,23,59,59)

        when:
         Date date= AppUtils.getCreateDate(date1, date2)
        then:
        date.getHours()-date1.getHours()==8

        when:
        Date date22= AppUtils.getCreateDate(date1, date3)
        then:
        date22.getHours()-date1.getHours()==23

        when:
        Date date33= AppUtils.getCreateDate(date1, date4)
        then:
        date33.getHours()-date1.getHours()==23

        when:
        Date date44= AppUtils.getCreateDate(date1, date5)
        then:
        date44.getHours()-date1.getHours()==0

        when:
        Date date55= AppUtils.getCreateDate(date1, null)
        then:
        date55.getHours()-date6.getHours()==0

    }

}
